import { QXEvent } from "qx-util";
import { IParam, DrtabActionType, IDrtabAbility, IDrtabControllerParams, IDrtabStore, DrtabController, ICtrlEvent, IDrtabController, IDrtabModel } from "@/core";
import { useDrtabAction, useDrtabBasic, useDrtabControllerParams, useDrtabProps } from "@/hooks/widget/use-drtab";
import { model } from "./default-drtab-model";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@DRTAB}}-drtab/{{spinalCase ctrl.codeName}}-drtab-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useDrtabProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useDrtabBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useDrtabAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<DrtabActionType, IDrtabAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<DrtabActionType, IDrtabAbility>>,
    otherParams: IParam = {},
): IDrtabController<IDrtabStore, IDrtabAbility> {
	const params: IDrtabControllerParams<DrtabActionType, IDrtabAbility> =
		useDrtabControllerParams<IDrtabStore, IDrtabModel>(model, props, evt, otherParams);
  	return new DrtabController(params);
}